<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/26
 * Time: 14:44
 */

namespace Admin\Controller;
use Think\Controller;
class CommonController extends Controller
{

    protected $param=[];

    function __construct()
    {
        parent::__construct();
        if(empty($_SESSION['id'])){
           $this-> redirect('Login/login');
        }
//        $param=$_POST;
//        $ip = getIP();
//        if(!in_array($ip,['223.93.134.2','58.101.46.30','49.87.235.68','36.24.72.53','112.244.92.218','49.87.192.114','119.176.119.51'])){
//            $this-> redirect('Login/login');
//        }
    }

    public function add_log($content){
        $str = array('aid' => $_SESSION['id'], 'content' =>$content, 'ctime' => time());
        M('admin_log', '', 'KEFU')->add($str);
    }

    public function ajax($code,$result,$r=''){
        if(empty($r)){
            $this->ajaxReturn(['code'=>$code,'result'=>$result,'data'=>$r]);
        }else{
            $this->ajaxReturn(['code'=>$code,'result'=>$result,'data'=>$r]);
            return false;
        }
    }

    //__constrct

}